home *** CD-ROM | disk | FTP | other *** search
- unit FilteredComponentProperty;
- interface
- uses Classes, DsgnIntf ;
- type
- TTestCompAbs = class( TComponent ) ;
- TTestComp = class( TTestCompAbs )
- private
- FParentComp : TTestCompAbs ;
- published
- property ParentComp : TTestCompAbs read FParentComp write FParentComp ;
- end ;
- TFilteredComponentProperty = class( TComponentProperty )
- private
- FInheritedProc : TGetStrProc ;
- procedure OurProc( const s : string ) ;
- function IsOurName( const s : string ) : boolean ;
- protected
- procedure GetValues( Proc : TGetStrProc ) ; override ;
- end ;
- procedure Register ;
- implementation
- function TFilteredComponentProperty.IsOurName( const s : string ) :
- boolean ;
- var i : integer ;
- begin
- Result := true ;
- for i := 0 to PropCount - 1 do
- if s = ( GetComponent( i ) as TComponent ).Name then exit ;
- Result := false ;
- end ;
- procedure TFilteredComponentProperty.OurProc( const s : string ) ;
- begin
- // only pass on if value is not our own name
- if not IsOurName( s ) then
- FInheritedProc( s ) ;
- end ;
- procedure TFilteredComponentProperty.GetValues( Proc : TGetStrProc ) ;
- begin
- FInheritedProc := Proc ;
- inherited GetValues( OurProc ) ;
- end;
- procedure Register ;
- begin
- RegisterComponents( 'Samples', [ TTestComp ] ) ;
- RegisterPropertyEditor( TypeInfo( TTestCompAbs ), TTestCompAbs, '',
- TFilteredComponentProperty ) ;
- end ;
- end.
-